﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ECS_Test
{
    public class GameState
    {
        public static List<ISystem> systems;
        public static EntityManager em;

        System sys_phy;
        System sys_mov;
        System sys_vis;

        public void Load()
        {
            // Populates a dictionary for fast enum<->string identification
            Components.SetupStringCompEnumsDict();

            // Create, load and add systems, specifying which components an entity must have to be processed by it
            systems = new List<ISystem>();
            sys_phy = new Sys_Physics(new CompTypes[] { CompTypes.Velocity,CompTypes.Position, CompTypes.Physics });
            sys_mov = new Sys_Movement(new CompTypes[] { CompTypes.Velocity, CompTypes.Position });
            sys_vis = new Sys_Graphics(new CompTypes[] { CompTypes.Position });
            systems.Add(sys_phy);
            systems.Add(sys_mov);

            // Create Entitity Manager and entites
            em = new EntityManager();

            em.AddEntity("man");
            em.AddEntity("wall");
        }
        public void Loop()
        {
            while (true)
            {
                sys_phy.Update();
                // For debug: 
                Comp_Velocity vel = (Comp_Velocity)GameState.em.allEntities[0].comps[CompTypes.Velocity];
                Console.Write("Velocity: "+vel.x + " " + vel.y + " " + vel.z+ " ");

                sys_mov.Update();
                
                // For debug: 
                Comp_Position pos = (Comp_Position)GameState.em.allEntities[0].comps[CompTypes.Position];
                Console.WriteLine("Position: " + pos.x + " " + pos.y + " " + pos.z);
                
                sys_vis.Update();
            }
        }
    }
}
